<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
FlyUI Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="sparql-service.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>FlyUI</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>sparql-service.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		This script defines a generic service class for running SPARQL queries.
 <BR/><BR/><B>Version: </B>$Revision:538 $ on $Date: 2008-08-27 09:08:41 +0100 (Wed, 27 Aug 2008) $ by $Author: aliman $
 <BR/><BR/><B>Requires:</B><UL>- <a href="../../flyui/util.html#">flyui.util</a><BR/>- <a href="../../flyui/sparql/Service.html#">flyui.sparql.Service</a><BR/>- YAHOO.util.Connect
 For license terms see http://flyui.googlecode.com</UL><B>Author:</B> <a href="http://purl.org/net/aliman">Alistair Miles</a>
 <BR/>
	
</p>

<hr>



<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 * <span class="attrib">@fileoverview</span>
 * This script defines a generic service class for running SPARQL queries.
 * <span class="attrib">@author</span> &lt;a href="http://purl.org/net/aliman"&gt;Alistair Miles&lt;/a&gt;
 * <span class="attrib">@version</span> $Revision:538 $ on $Date: 2008-08-27 09:08:41 +0100 (Wed, 27 Aug 2008) $ by $Author: aliman $
 * <span class="attrib">@requires</span> flyui.util
 * <span class="attrib">@requires</span> flyui.sparql.Service
 * <span class="attrib">@requires</span> YAHOO.util.Connect
 * For license terms see http://flyui.googlecode.com
 */</span>


flyui.namespace(<span class="literal">"flyui.sparql"</span>);


<span class="comment">/**
 * <span class="attrib">@class</span>
 */</span>
flyui.sparql.Service = <span class="reserved">function</span>() {};


<span class="comment">/**
 * <span class="attrib">@param</span> {String} url
 */</span>
flyui.sparql.Service.<span class="reserved">prototype</span>.setEndpoint = <span class="reserved">function</span>( url ) {
    <span class="reserved">this</span>._endpoint = url;
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * <span class="attrib">@type</span> String
 */</span>
flyui.sparql.Service.<span class="reserved">prototype</span>._endpoint = null;


<span class="comment">/**
 * <span class="attrib">@param</span> {String} query
 * <span class="attrib">@param</span> {Function} success
 * <span class="attrib">@param</span> {Function} failure
 */</span>
flyui.sparql.Service.<span class="reserved">prototype</span>.query = <span class="reserved">function</span>( query, success, failure ) {
	var _context = <span class="literal">"flyui.sparql.Service.prototype.query"</span>;
	try {
	    flyui.info(<span class="literal">"query: "</span>+query, _context);
    
	    flyui.debug(<span class="literal">"define the callback object"</span>, _context);
	    var callback = {
	        success: success,
	        failure: failure
	    };
	            
        <span class="comment">// output=json not necessary for sparqlite, but keep for compatibility with virtuoso</span>
	    var url = <span class="reserved">this</span>._endpoint + <span class="literal">"?query="</span>+escape(query)+<span class="literal">"&amp;output=json"</span>;
	    
	    flyui.debug(<span class="literal">"spike string length, expect 4: "</span>+<span class="literal">"abcd"</span>.length, _context);
	    flyui.debug(<span class="literal">"url length: "</span>+url.length, _context);
	    flyui.debug(<span class="literal">"make the request to "</span>+url, _context);
	    
		YAHOO.util.Connect.initHeader(<span class="literal">"Accept"</span>, <span class="literal">"application/sparql-results+json"</span>, true);    
	    YAHOO.util.Connect.asyncRequest(<span class="literal">"GET"</span>, url, callback);
	} catch (error) {
		flyui.debug(<span class="literal">"wrap and rethrow error to get a stack trace"</span>, _context);
        throw new flyui.UnexpectedException(_context, error);
	}    
};

flyui.sparql.Service.<span class="reserved">prototype</span>.postQuery = <span class="reserved">function</span>( query, success, failure ) {
	var _context = <span class="literal">"flyui.sparql.Service.prototype.postQuery"</span>;
	try {
        flyui.info(<span class="literal">"query: "</span>+query, _context);
        
        flyui.debug(<span class="literal">"define the callback object"</span>, _context);
        var callback = {
            success: success,
            failure: failure
        };
                
        var url = <span class="reserved">this</span>._endpoint;
        
        flyui.debug(<span class="literal">"make the request to "</span>+url, _context);
        
        <span class="comment">// output=json not necessary for sparqlite, but keep for compatibility with virtuoso</span>
        var content = <span class="literal">"query="</span>+escape(query)+<span class="literal">"&amp;output=json"</span>;
        flyui.debug(<span class="literal">"POST content: "</span>+content, _context);        
        YAHOO.util.Connect.initHeader(<span class="literal">"Accept"</span>, <span class="literal">"application/sparql-results+json"</span>, true);    
        YAHOO.util.Connect.asyncRequest(<span class="literal">"POST"</span>, url, callback, content);
        
	} catch (error) {
		flyui.debug(<span class="literal">"wrap and rethrow error to get a stack trace"</span>, _context);
        throw new flyui.UnexpectedException(_context, error);
	}
}


</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>FlyUI</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Tue Dec  9 11:08:18 2008</div>
</body>
</html>
